#include <stdio.h>
#include <string.h>

void Next(char *T, int *next, int n);

int main(void) {

  int n, i;
  char T[20];

  scanf("%s", T);
  n = strlen(T);
  int next[n];

  Next(T, next, n);
  for (i = 0; i < n; i++) {
    printf("%d\n", next[n]);
  }

  return 0;
}

void Next(char *T, int *next, int n) {

  next[0] = 0;
  int len = 0;
  int i = 1;

  while (i < n) {
    if (next[i] == next[len]) {
      len++;
      next[i] = len;
      i++;
    } else {
      if (len > 0) {
        len = next[len - 1];
      } else {
        next[i] = len;
        i++;
      }
    }
  }
}
